package cate.game.play.skill.passive.god;

import cate.common.util.XT;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.SkillActionCtx;
import cate.game.play.skill.passive.PassiveHandler;

/**
 * 攻击时40%概率附加【绝对零度】；受击2次后解除，解除时受到施法者攻击力40%的伤害，至多2目标
 */
public class 绝对零度PH extends PassiveHandler {

	private int 概率;

	private int buff;

	private int 人数;

	//概率=4000&buff=？？&人数=2
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		概率 = args.getInt("概率", 0);
		buff = args.getInt("buff", 0);
		人数 = args.getInt("人数", 0);
	}

	@Override
	public void onSkillDone(SkillActionCtx action) {
		if (!action.getSkill().cfg.isHurtSkill()) {
			return;
		}
		if (XT.isBlank(action.getTargets())) {
			return;
		}
		int addNum = 0;
		for (Fighter target : action.getTargets()) {
			if (target.buff.tryAddByTid(action, skill.owner, buff, 概率) > 0) {
				addNum++;
				if (addNum >= 人数) {
					return;
				}
			}
		}
	}
}
